<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>
<SCRIPT type="text/javascript">
  function doc_upload_success(file, data) {
        var json = $.parseJSON(data)
        
        $(this).bjuiajax('ajaxDone', json)
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $('#doc_pic').val(json.filename)
            $('#doc_span_pic').html('已上传图片：<img src="'+ json.filename +'" width="100">')
        }else{
        	alert(json.msg);   
        }
    }
    
	$(document).ready(function(){
		$("#staffNum").val('');
		$("#loginPwd").val("");
		
		$("#staffNum").bind("blur", function(){
			var staffNum = $("#staffNum").val();
			$.ajax({   
			    url:'${ctx}/management/staff/checkStaffNum.do?staffNum='+staffNum,   
			    type:'post',   
			    async : true, //默认为true 异步   
			    error:function(){   
			       alert('error');   
			    },   
			    success:function(data){
			    	var rtnObj = eval('(' + data + ')');
			    	if(!rtnObj.isFlag){
			    		$("#staffNum").alertmsg('error', rtnObj.msg);
			    		$("#staffNum").val("");
			    	}
			    }
			});
		})
	})
	
	
	//选择事件
function S_NodeCheck(e, treeId, treeNode) {
    var zTree = $.fn.zTree.getZTreeObj(treeId),
        nodes = zTree.getCheckedNodes(true)
    var ids = '', names = ''
    
    for (var i = 0; i < nodes.length; i++) {
        ids   += ','+ nodes[i].id
        names += ','+ nodes[i].name
    }
    if (ids.length > 0) {
        ids = ids.substr(1), names = names.substr(1)
    }
    $("#roleids").val(ids);
    var $from = $('#'+ treeId).data('fromObj')
    
    if ($from && $from.length) $from.val(names)
}
//单击事件
function S_NodeClick(event, treeId, treeNode) {
    var zTree = $.fn.zTree.getZTreeObj(treeId)
    
    zTree.checkNode(treeNode, !treeNode.checked, true, true)
    
    event.preventDefault()
}
</SCRIPT>	
<div class="bjui-pageContent">
    
    <form action="${ctx}/management/staff/add.do" data-toggle="validate" data-reload-navtab="true">
	   <div style="margin:5px auto 0; width:92%;">
	        <div class="row" >
	       	 	   <div class="col-md-6">
	       	 	     <table class="table table-condensed table-hover" width="100%">
	       	 	       <tbody style="padding-left: 23px;">
	       	 	         <tr>
                	 		 <td> 
                	 		 	 <label class="control-label">员工姓名：</label>
	                     		 <input type="text" name="staffName"  data-rule="required" value="" size="20">
                	 		  </td>
	       	 	         </tr>
	       	 	         
	       	 	          <tr>
                	 		 <td> 
                	 		 	 <label class="control-label">所属部门：</label>
	                     		 <input type="text" id="orgName" name="orgName"  data-rule="required" value="${vo.orgName}" size="20" readonly>
	                     		 <input type="hidden" name="orgCode" value="${vo.orgCode}" size="20">
                	 		  </td>
	       	 	         </tr>
	       	 	           <tr>
                	 		 <td> 
                	 		 	 <label class="control-label">员工工号：</label>
	                     		 <input type="text" id="staffNum" name="staffNum"  data-rule="required" value="" size="20">
	                     		 <input type="hidden" name="orgCode" value="${vo.orgCode}" size="20">
                	 		  </td>
	       	 	         </tr>
	       	 	          <tr>
                	 		 <td> 
               	 		 		<label class="control-label">登录密码：</label>
                     		 	<input type="password" id="loginPwd" name="loginPwd" data-rule="required" value="" size="20">
                	 		  </td>
	       	 	         </tr>
	       	 	         
	       	 	          <tr>
                	 	  	 <td> 
                	 		 	 <label class="control-label">系统角色：</label>
                	 		 	 
                	 		 	    <input type="hidden" id="roleids"  name="roleids" value="">
						             <input type="text" id="roleNames" name="roleNames" value="${param.roleNames}" data-toggle="selectztree" size="20" data-tree="#addRoleTree" readonly>
						              <ul id="addRoleTree" class="ztree hide" data-toggle="ztree" data-expand-all="true" data-check-enable="true" data-on-check="S_NodeCheck" data-on-click="S_NodeClick">
						              	<c:forEach var="paramObj" items="${roleList}">
						               	 	<li data-id="${paramObj.intID}" data-pid="0">${paramObj.roleName}</li>
						                </c:forEach>
						            </ul>
                	 		  </td>
	       	 	          </tr>
	       	 	         
	       	 	         
	       	 	          <tr>
                	 		 <td> 
                	 		 	 <label class="control-label">员工姓名：</label>
	                     		 <input type="text" name="staffName"  data-rule="required" value="" size="20">
                	 		  </td>
	       	 	         </tr>
	       	 	          <tr>
                	 		 <td> 
                	 		 	 <label class="control-label"> &nbsp;&nbsp;性&nbsp;别&nbsp;&nbsp;&nbsp;： </label>
	                     		 <select class="selectpicker show-tick" name="psex" data-width="200"  data-toggle="selectpicker" >
	                           		<c:forEach var="paramObj" items="${SYS_PSEX}">
	                           			 <option value="${paramObj.value2}" <c:if test="${paramObj.value2 eq vo.psex}">selected="selected"</c:if>>${paramObj.value1}</option>
	                            	 </c:forEach>
	                       		 </select>
                	 		  </td>
	       	 	         </tr>
	       	 	        
		                </tbody>
		            </table>
	          		</div>
		           <div class="col-md-4">
                       <div class="panel" title="员工照片">
		                        <div style="display:inline-block; vertical-align:middle;">
							    <div id="doc_pic_up" data-toggle="upload" data-uploader="${ctx}/management/staff/uploadUserPic.do" 
							        data-file-size-limit="1024000000"
							        data-file-type-exts="*.jpg;*.png;*.gif;*.mpg"
							        data-multi="true"
							        data-on-upload-success="doc_upload_success"
							        data-icon="cloud-upload"></div>
							    <input type="hidden" name="pimg" value="" id="doc_pic">
							</div>
							<span id="doc_span_pic"></span>
		                </div>
		          </div>
	        </div>
	    </div>
    
        <div class="pageFormContent" data-layout-h="0" style="margin:5px auto 0; width:92%;">
            <table class="table table-condensed table-hover" width="98%">
                <tbody>
                	 <tr>
                	 	<td>
                            <label class="control-label x100">证件号码：</label>
                            <input type="text" name="identityNum"  data-rule="required;ID_card" value="" size="20">
                        </td>
                        <td>
                            <label class="control-label x100">薪资级别：</label>
                              <select class="selectpicker show-tick" name="basePay"  data-width="200" data-toggle="selectpicker" >
                           		<c:forEach var="paramObj" items="${SYS_BASEPAY}">
                           			 <option value="${paramObj.value2}" <c:if test="${paramObj.value2 eq vo.basePay}">selected="selected"</c:if>>${paramObj.value1}</option>
                            	 </c:forEach>
	                        </select>
	                        
                        </td>
                 	   </tr>
                 	   <tr>
                        <td>
                            <label class="control-label x100">职务：</label>
                            <select class="selectpicker show-tick" name="posiTion"  data-width="200" data-rule="required"  data-toggle="selectpicker" >
                           		<c:forEach var="paramObj" items="${SYS_POSITION}">
                           			 <option value="${paramObj.value2}" <c:if test="${paramObj.value2 eq vo.posiTion}">selected="selected"</c:if>>${paramObj.value1}</option>
                            	 </c:forEach>
	                        </select>
                        </td>
                   
                        <td>
                            <label class="control-label x100">入司时间：</label>
                            <input type="text" name="entryDate" value="${vo.entryDate}" size="20"  data-toggle="datepicker" data-rule="required;date">
                        </td>
                      </tr>
                       <tr>
                        <td>
                            <label class="control-label x100">负责人：</label>
                            <input type="text" name="leaderStaffName" value="" size="20">
                        </td>
                        <td>
                            <label class="control-label x100">转正日期：</label>
                            <input type="text" name="fullDate" value="${vo.fullDate}" size="20" data-toggle="datepicker" data-rule="required;date">
                        </td>
                    </tr>
                      <tr>
                        <td >
                            <label class="control-label x100">联系电话：</label>
                            <input type="text" name="ptel"  data-rule="required" value="" size="20">
                        </td>
                         <td>
                            <label class="control-label x100">分机号：</label>
                            <input type="text" name="extPhone" value="" size="20">
                        </td>
                     </tr>
                     <tr>
                        <td>
                            <label class="control-label x100">MSN/QQ：</label>
                            <input type="text" name="contMsg" value="" size="20">
                        </td>
                       	<td>
                            <label class="control-label x100">EMAIL：</label>
                            <input type="text" name="email" value="" data-rule="email"   size="20">
                        </td>
                     </tr>
                     <tr>
                        <td>
                            <label class="control-label x100">出生日期：</label>
                            <input type="text" name="birthDate" value=""  value="1985-08-08" data-toggle="datepicker" data-rule="required;date" size="20">
                        </td>
                        <td >
                            <label class="control-label x100">联系地址：</label>
                            <input type="text" name="contactAddr" value="" size="20">
                        </td>
                    </tr>
                 	<tr>
                        <td>
                            <label class="control-label x100">在职状态：</label>
                            <select class="selectpicker show-tick" name="sysStatus" data-width="200"  data-toggle="selectpicker" >
                           		<c:forEach var="paramObj" items="${SYS_SYSSTATUS}">
                           			 <option value="${paramObj.value2}" <c:if test="${paramObj.value2 eq vo.sysStatus}">selected="selected"</c:if>>${paramObj.value1}</option>
                            	 </c:forEach>
	                        </select>
                        </td>
                        <td>
                            <label class="control-label x100">备注：</label>
                            <input type="text" name="remark" value="" size="20">
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </form>
</div>

<div class="bjui-pageFooter">
    <ul>
        <li><button type="submit" id="btn1" class="btn-default" data-icon="save">保存</button></li>
        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
      
    </ul>
</div>